import { Fragment } from '@/components/Fragment'; import { Placeholder } from '@aws-amplify/ui-react'; import { PlaceholderDemo } from './demo'; import { DefaultPlaceholderExample, PlaceholderIsLoadedExample, PlaceholderSizeExample, PlaceholderStylePropsExample, PlaceholderThemeExample, } from './examples'; import { Example, ExampleCode } from '@/components/Example'; import { ComponentStyleDisplay } from '@/components/ComponentStyleDisplay'; import ThemeExample from '@/components/ThemeExample.mdx'; ## Demo ## Usage Import the Placeholder component. ```jsx file=./examples/DefaultPlaceholderExample.tsx ``` ### isLoaded Use `isLoaded` prop to indicate whether or not the content is loaded. ```jsx file=./examples/PlaceholderIsLoadedExample.tsx ``` ### Sizes Use the `size` prop to change the Placeholder size. Available options are `small`, `large`, and none (default). ```jsx file=./examples/PlaceholderSizeExample.tsx ``` ## Customization ```tsx file=./examples/PlaceholderThemeExample.tsx ``` ### Target classes ### Global styling To override styling on all Placeholder components, you can set the Amplify CSS variables or use the built-in `.amplify-placeholder` class. ```css /* styles.css */ [data-amplify-theme] { --amplify-components-placeholder-height: var(--amplify-space-xl); --amplify-components-placeholder-border-radius: var(--amplify-space-medium); } /* OR */ .amplify-placeholder { height: var(--amplify-space-xl); border-radius: var(--amplify-space-medium); } ``` ```jsx ``` ### Local styling To override styling on a specific Placeholder, you can use a class selector or style props. _Using a class selector:_ Set the starting and ending colors for the Placeholder animation using a custom CSS class with the Amplify CSS variables: ```css /* styles.css */ .placeholder-local-styles { --amplify-components-placeholder-start-color: var(--amplify-colors-purple-80); --amplify-components-placeholder-end-color: var(--amplify-colors-blue-80); } ``` ```jsx import './styles.css'; ``` _Using style props:_ ```jsx file=./examples/PlaceholderStylePropsExample.tsx ```